package org.bill.type;

public enum Group {

    /**
     * 普通人员
     */
    ORAINARY(1, "普通人员"),
    /**
     * 代理
     */
    AGENT(2, "代理"),
    /**
     * 管理员
     */
    ADMIN(3, "管理员");

    private final int index;
    private final String name;

    private Group(int index, String name) {
        this.index = index;
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public int getIndex(String name) {
        int result = 0;
        if (name == null || name.equals("")) {
            return result;
        }

        for (Group g : Group.values()) {
            if (g.getIndex() == index) {
                result = g.index;
                break;
            }
        }
        return result;
    }

    public String getName() {
        return name;
    }

    public String getName(int index) {
        String result = null;
        if (index < 1) {
            return result;
        }

        for (Group g : Group.values()) {
            if (g.getIndex() == index) {
                result = g.name;
                break;
            }
        }
        return result;
    }

}
